<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>

<!-- 搜索框 -->
管理员名称：<input id="adminUsername"/>
<input type="button" value="搜索" onclick="doSearch()"><br>
<!-- 搜索框 ==END==-->

<!-- datagrid数据表格 -->
<table id="myDatagridlog"></table>
<!-- datagrid数据表格==END== -->

<!-- 按钮 -->
<div id="myBtnDivlog">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="toDelete()">批量删除</a>
</div>
<!-- 按钮===END=== -->

<script type="text/javascript">
    $(function () {

        /* datagrid展示数据 */
        $("#myDatagridlog").datagrid({
            url: '${pageContext.request.contextPath}/log/showAll',
            pagination: true,
            columns: [[
                {checkbox:true},
                {field: 'logId', title: '日志编号'},
                {field: 'logContent', title: '日志内容'},
                {field: 'adminUsername', title: '用户名'},
                {field: 'logDate', title: '时间'},
                {field: 'logIp', title: '用户ip'}
            ]],
            toolbar: '#myBtnDivlog'
        });
        /* datagrid展示数据  结束 */

    });

    /* 搜索 */
    function doSearch() {
        var adminUsername = $("#adminUsername").val();
        $("#myDatagridlog").datagrid("reload", {"adminUsername": adminUsername});
    }
    /* 搜索结束*/


    /* 批量删除 */
    function toDelete(){
        var allSelectedRows=$("#myDatagridlog").datagrid("getSelections");
        var ids=new Array();

        for(var i=0;i<allSelectedRows.length;i++){
            ids[i]=allSelectedRows[i].logId;
        }

        $.ajax({
            url:"${pageContext.request.contextPath}/log/delete",
            data:"ids="+ids,
            type:"post",
            dataType:"JSON",
            success:function(data){
                if(data.flag){
                    $("#myDatagridlog").datagrid("reload");
                }else{
                    $.messager.alert('提示框','删除失败，请确认！','warning');
                }
            }
        });
    }
    /* 批量删除 */

</script>